﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Media;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace SimpleConnection_UDP_WIN.utils
{
    internal class SoundUtil
    {
        public static void palySound(string path)
        {
            // 创建一个SoundPlayer对象
            SoundPlayer player = new SoundPlayer
            {
                // 设置要播放的声音文件路径
                SoundLocation = path
            };
            // 加载声音文件
            player.Load();
            // 播放声音
            player.Play();
            player.Dispose();

        }
        public static void palySound(Stream soundStream)
        {
            // 创建一个SoundPlayer对象
            SoundPlayer player = new SoundPlayer(soundStream);
            // 加载声音文件
            player.Load();
            // 播放声音
            player.Play();
            player.Dispose();
            soundStream.Close();
        }

        /// <summary>
        /// 播放提示音
        /// </summary>
        public static void playReminderTone()
        {

                //调用 内容嵌入资源
                string soundResourceName = "VideoMergeSplitApp.src.ok2.wav"; // 声音资源的名称
                Assembly assembly = Assembly.GetExecutingAssembly();
                Stream soundStream = assembly.GetManifestResourceStream(soundResourceName);

                palySound(soundStream);

        }


    }
}
